/* eslint-disable import/no-anonymous-default-export */
import {
    homeData,
    indexDashboard
} from '../services/homeApi';

export default {
    state: {
        data: [],
        echartsData: [],
        getAdminMenuListData: []
    },
    effects: {
        /* 获取用户列表 */
        async homeData(params) {
            const response = await homeData(params);
            if (response.code === 200) {

                this.saveHomeinfo(response)
            }
        },
        async indexDashboard(params) {
            const response = await indexDashboard(params)

            if (response.code === 200) {
                this.saveIndexDashboard({
                    echartsData: response.data
                })
            }
        },

    },

    reducers: {
        saveIndexDashboard(state, payload) {
            return {
                ...state,
                ...payload
            }
        },
        saveHomeinfo(state, payload) {
            return {
                ...state,
                ...payload
            }
        },

    }
}